using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using AtletIS.DomainModel.Entities.Main;

namespace AtletIS.Database.Mapping.Main
{
    public class CheckPointMap : EntityTypeConfiguration<CheckPoint>
    {
        public CheckPointMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Name)
                .HasMaxLength(100);

            this.Property(t => t.PcId)
                .HasMaxLength(10);

            this.Property(t => t.BoardName)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("CheckPoints");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.DisciplineListId).HasColumnName("DisciplineListId");
            this.Property(t => t.OrderInDiscipline).HasColumnName("OrderInDiscipline");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.Code).HasColumnName("Code");
            this.Property(t => t.PcId).HasColumnName("PcId");
            this.Property(t => t.LapCount).HasColumnName("LapCount");
            this.Property(t => t.BoardName).HasColumnName("BoardName");
            this.Property(t => t.Active).HasColumnName("Active");
            this.Property(t => t.Sync).HasColumnName("Sync");
            this.Property(t => t.WebId).HasColumnName("WebId");
            this.Property(t => t.Modified).HasColumnName("Modified");

            // Relationships
            this.HasOptional(t => t.DisciplineList)
                .WithMany(t => t.CheckPoints)
                .HasForeignKey(d => d.DisciplineListId);

        }
    }
}
